<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title></title>
		<link rel="stylesheet" type="text/css" href="/hairring/Public/Admin/css/index.css"/>
	</head>

	<body>
		<form id="form" action="<?php echo U('Carousel/insert');?>" method="post" enctype="multipart/form-data">
			URL：<input type="text" name="url" autocomplete="off" />
			ORDER：<select name="ordernum">
				<option value="1">1</option>
				<option value="2">2</option>
				<option value="3">3</option>
				<option value="4">4</option>
				<option value="5">5</option>
			</select>
			<div class="img"></div>
			<input type="hidden" id="img-post" name="img" value="" />
			上传图片：<input type="file" id="file" name="ups" accept="image/gif, image/jpeg, image/png, image/jpg, image/webp">
			<input type="submit" value="添加"/>
		</form>
		
		
		<script src="/hairring/Public/js/jquery-3.3.1.min.js" type="text/javascript" charset="utf-8"></script>
		
		
		<script type="text/javascript">
			$(function() {
				$("#file").change(function () {
					var form = $("#form")[0];
					var formData = new FormData(form);
					
					$.ajax({
						type: "post",
						url: "<?php echo U('Carousel/ajax_img');?>",
						data: formData,
						async: true,
						cache: false,
						contentType: false,
						processData: false,
						success: function(data) {
							if(data) {
								$("#img-post").val(data);
								var img = "<img src='/hairring/Uploads/" + data + "' width='200' height='200'/>";
								$(".img").html(img);
							}
						}
					});
				})
			})
		</script>
	</body>

</html>